package vn.edu.ptithcm.pim.dao;

import java.util.List;

import org.hibernate.LockMode;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import vn.edu.ptithcm.pim.dom.Language;

public class LanguageDao extends HibernateDaoSupport{
	public void save(Language language) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().save(language);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void saveOrUpdate(Language language) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().saveOrUpdate(language);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void lock(Language language) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().lock(language, LockMode.NONE);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public void delete(Language language) {
		try {
			Transaction tx = getSession().beginTransaction();
			getHibernateTemplate().delete(language);
			tx.commit();
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Language merge(Language language) {
		try {
			return (Language) getHibernateTemplate().merge(language);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	public Language findById(java.lang.Long id) {
		try {
			return (Language) getHibernateTemplate().get(Language.class, id);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	@SuppressWarnings("rawtypes")
	public List findByExample(Language language) {
		try {
			return getHibernateTemplate().findByExample("Language", language);
		} catch (RuntimeException re) {
			throw re;
		}
	}

	@SuppressWarnings("rawtypes")
	public List getAll() {
		try {
			return getHibernateTemplate().loadAll(Language.class);
		} catch (RuntimeException re) {
			throw re;
		}
	}
}
